﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using EntityModel;

namespace OA.DataBase
{
    public class OAInitializer : DropCreateDatabaseIfModelChanges<OAContext>
    {
        protected override void Seed(OAContext context)
        {
            base.Seed(context);
            Module module0 = new Module()
            {
                ModuleName = "系统管理",
                Href = "#",
                iconCls = "icon-monitor",
                Parent = null,
                CheckInTime = DateTime.Now,
                DataState = false,
                Sort = 1
            };

            Module module1 = new Module()
                  {
                      ModuleName = "模块视图",
                      Href = "/Module/Index",
                      iconCls = "icon-moduleview",
                      Parent = module0,
                      CheckInTime = DateTime.Now,
                      DataState = false,
                      Sort = 1
                  };
            Module module2 = new Module()
                  {
                      ModuleName = "菜单管理",
                      Href = "/SysAction/Index",
                      iconCls = "icon-menu",
                      Parent = module0,
                      CheckInTime = DateTime.Now,
                      DataState = false,
                      Sort = 2
                  };
            Module module3 = new Module()
                  {
                      ModuleName = "人事管理",
                      Href = "#",
                      iconCls = "icon-group",
                      Parent = null,
                      CheckInTime = DateTime.Now,
                      DataState = false,
                      Sort = 2
                  };
            Module module4 = new Module()
                  {
                      ModuleName = "人员管理",
                      Href = "#",
                      iconCls = "icon-user",
                      Parent = module3,
                      CheckInTime = DateTime.Now,
                      DataState = false,
                      Sort = 1
                  };
            Module module5 = new Module()
                 {
                     ModuleName = "部门管理",
                     Href = "#",
                     iconCls = "icon-dep",
                     Parent = module3,
                     CheckInTime = DateTime.Now,
                     DataState = false,
                     Sort = 2
                 };
            var moudules = new List<Module>();
            moudules.Add(module0);
            moudules.Add(module1);
            moudules.Add(module2);
            moudules.Add(module3);
            moudules.Add(module4);
            moudules.Add(module5);
            moudules.ForEach(m => context.Modules.Add(m));

            List<SysAction> sysactions = new List<SysAction>()
            {
                new SysAction()
                {
                     SysActionName="新增",
                     IcoUrl="",
                     CheckInTime=DateTime.Now
                },
                new SysAction()
                {
                     SysActionName="修改",
                     IcoUrl="",
                     CheckInTime=DateTime.Now
                },
                new SysAction()
                {
                     SysActionName="查看",
                     IcoUrl="",
                     CheckInTime=DateTime.Now
                },
                new SysAction()
                {
                     SysActionName="编辑",
                     IcoUrl="",
                     CheckInTime=DateTime.Now
                },
                new SysAction()
                {
                     SysActionName="删除",
                     IcoUrl="",
                     CheckInTime=DateTime.Now
                }
            };
            sysactions.ForEach(sysm => context.SysActions.Add(sysm));


            context.SaveChanges();
        }
    }
}
